{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_radviz:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Radviz\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Radviz maps a higher dimensional space with a non-linear function to two dimensions.\n",
    "Let us visualize some test data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.util.ref_dirs import get_reference_directions\n",
    "from pymoo.problems import get_problem\n",
    "\n",
    "\n",
    "ref_dirs = get_reference_directions(\"uniform\", 6, n_partitions=5)\n",
    "F = get_problem(\"dtlz1\").pareto_front(ref_dirs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A simple Radviz plot with points can be created by:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.visualization.radviz import Radviz\n",
    "Radviz().add(F).show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The plot can be further customized by supplying a title, labels, and by using the plotting directives from matplotlib. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot = Radviz(title=\"Optimization\",\n",
    "              legend=(True, {'loc': \"upper left\", 'bbox_to_anchor': (-0.1, 1.08, 0, 0)}),\n",
    "              labels=[\"profit\", \"cost\", \"sustainability\", \"environment\", \"satisfaction\", \"time\"],\n",
    "              endpoint_style={\"s\": 70, \"color\": \"green\"})\n",
    "plot.set_axis_style(color=\"black\", alpha=1.0)\n",
    "plot.add(F, color=\"grey\", s=20)\n",
    "plot.add(F[65], color=\"red\", s=70, label=\"Solution A\")\n",
    "plot.add(F[72], color=\"blue\", s=70, label=\"Solution B\")\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that radviz plots are by default normalized."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### API"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. autoclass:: pymoo.visualization.radviz.Radviz\n",
    "    :noindex:"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
